package com.lz.redis.common.redis.queue;

import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Component;

/**
 *  订阅者类（Subscriber）
 * 订阅指定频道，并处理该频道的消息。
 * */

@Component
public class RedisSubscriber implements MessageListener {
    @Override
    public void onMessage(Message message, byte[] pattern) {
        String channel = new String(message.getChannel());
        String body = new String(message.getBody());
        System.out.println("Subscriber 接收到来自:" + channel + "频道的消息体:" + body);
        //处理消息
    }
}